package com.winning.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.winning.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Date;

/**
 * 请求参数实体类
 *
 * @author z_dd@winning.com.cn
 * @date 2019/1/22 14:15
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Component()
public class RequestSet implements Serializable {


    /**
     * 客户端生成的请求唯一标识[UUID]
     */
    @JSONField(ordinal = 1)
    private String requestId;
    /**
     * 认证信息
     */
    @JSONField(ordinal = 2)
    private String securityToken;
    /**
     * 调用模块代码
     */
    @JSONField(ordinal = 3)
    private String modularCode;
    /**
     * 操作代码
     */
    @JSONField(ordinal = 5)
    @Value("${com.winning.appid}")
    private String actionCode;
    /**
     * 接口类型
     */
    @JSONField(ordinal = 4)
    private String interfaceType;

    /**
     * 请求时间,格式：yyyy-MM-dd HH:mm:ss
     */

    @Value("#{new java.util.Date()}")
    @JSONField(ordinal = 6, format = "yyyy-MM-dd HH:mm:ss")
    private Date requestTime;

    /**
     * 请求参数，封装请求业务数据
     */
    @JSONField(ordinal = 7)
    private JSON requestParams;

    /**
     * 请求内容校验码
     */
    @JSONField(ordinal = 8)
    private String verifyCode;


    public String getRequestId() {
        return StringUtils.getUUID();
    }
}
